#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
	int ans=0,f=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		ans=(ans<<1)+(ans<<3)+(c^48);
		c=getchar();
	}
	return ans*f;
}

struct nod{
	int dis,v,s;
}a[100010];

int ans,n,m,l,v,t,g[100010],cnt,dp[100010],vh1[100010],vh[3010][3010];

void dfs(int s,int k){
	fill(vh1,vh1+ans+1,0);
	if(s>m){
		for(int i=1;i<k;++i){
			for(int j=1;j<=ans;++j){
				if(vh[j][dp[i]]==1){
					vh1[j]=1;
				}
			}
		}
		bool f=true;
		for(int i=1;i<=ans;++i) if(vh1[i]==0) f=false;
		if(f) cnt=min(cnt,k-1);
		return ;
	}
	dp[k]=s;
	dfs(s+1,k+1);
	dp[k]=0;
	dfs(s+1,k);
}

int lower(int l,int r,int x){
	while(l+1<r){
		int mid=(l+r)>>1;
		if(g[mid]<x) l=mid;
		else r=mid;
	}
	return r;
}

signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	t=read();
	while(t--){
		n=read(),m=read(),l=read(),v=read();
		ans=0;
		bool f0=true;
		for(int i=1;i<=n;++i) a[i].dis=read(),a[i].v=read(),a[i].s=read();
		for(int i=1;i<=m;++i) g[i]=read();
		for(int i=1;i<=n;++i){
			if(a[i].s!=0) f0=false;
		}
		if(f0){
			int sd=0,ss=1,id=0;
			for(int i=1;i<=n;++i){
				if(a[i].v>v){
					int k=lower(0,m+1,a[i].dis);
					if(k==m+1) continue;
					sd++;
					ss=0;
				}
			}
			cout<< sd << " " << (ss==1?m:m-1) << endl;
		}else{
			for(int i=1;i<=n;++i){
				int f=1;
				for(int j=1;j<=m;++j){
					if(a[i].dis<=g[j]){
						if((g[j]-a[i].dis)*2*a[i].s+pow(a[i].v,2)<=0){
							break;
						}
						int k=(int)ceil((double)sqrt((double)((g[j]-a[i].dis)*2*a[i].s+pow(a[i].v,2))));
						//cout<< k << " ";
						if(k>v){
							if(f==1) ans++,f=0;
							vh[ans][j]=1;
						}
					}
				}
			}
			cout<< ans << " ";
			cnt=1e18;
			dfs(1,1);
			cout<< m-cnt << endl;
			for(int i=1;i<=ans;++i){
			for(int j=1;j<=m;++j) vh[i][j]=0;
			}
		}
	}
	return 0;
}

